

<?php

if (getParameter("newcommand")=="true") $_SESSION['nocommand']=false;

if (getParameter("newcommand")=="false" || getParameter("newcommand")==null ) $_SESSION['nocommand']=true;
//!isset($_SESSION['nocommand']) ||
if ( $_SESSION['nocommand']==true )

{?>
<div> <input type="button" class="newcommand" value="Nouvelle Commande" onclick="javascript:location.href='<?php echo createUrl("newcommand","true")?>';"> </div>
<?php
}else{
//$_SESSION['nocommand']=false;

//supprimePanier();
?>

<div class="shop">
<div class="caisse">
<!--
<div class="title">Caisse</div>
-->

<!--
<div class="product">


Produit :
<input id="product" />
</div>
-->

    <div class="barcode"> <img src="/portalfiles/omnipharma/image/barcodeicon.gif" alt="Code Ã  barres" /><input  value="" type="text" id="barCode" name="barCode"/></div>
<br clear="all" />



    <div id="msg"></div>

    <table width="100%">
        <tr valign="top"><td width="100%">


            <div id="caisse"><div class="top">
                </div>
                <table width="100%">
                    <tr class="toptable">

                        <td width="15px"></td>
                        <td>Article</td>
                        <TD>Forme</td>
                        <TD>Quantité</td>
                        <td>Prix</td>
                        <td>Sous Total</td>
                        <td>Stock</td>
                        <td style="width: 72px;">Supprimer</td>
                    </tr>

                </table>
                <div class="bottom">
                </div>

            </div>


</div>


<div id="result"></div>

<br clear="all"/>


<input name="ReadOut" type="Text" size=24 value="0" width=100%>
        </td>
            <td width="184px">

                <FORM name="Keypad" action="" class="keypad">

                            <TABLE border=0 width=60 height=60 cellpadding=1 cellspacing=5>

                                <TR>
                                    <TD>
                                        <input name="btnSeven" type="Button" value="  7  " onclick="NumPressed(7)">
                                    </TD>
                                    <TD>
                                        <input name="btnEight" type="Button" value="  8  " onclick="NumPressed(8)">
                                    </TD>
                                    <TD>
                                        <input name="btnNine" type="Button" value="  9  " onclick="NumPressed(9)">
                                    </TD>


                                </TR>
                                <TR>
                                    <TD>
                                        <input name="btnFour" type="Button" value="  4  " onclick="NumPressed(4)">
                                    </TD>
                                    <TD>
                                        <input name="btnFive" type="Button" value="  5  " onclick="NumPressed(5)">
                                    </TD>
                                    <TD>
                                        <input name="btnSix" type="Button" value="  6  " onclick="NumPressed(6)">
                                    </TD>


                                </TR>
                                <TR>
                                    <TD>
                                        <input name="btnOne" type="Button" value="  1  " onclick="NumPressed(1)">
                                    </TD>
                                    <TD>
                                        <input name="btnTwo" type="Button" value="  2  " onclick="NumPressed(2)">
                                    </TD>
                                    <TD>
                                        <input name="btnThree" type="Button" value="  3  " onclick="NumPressed(3)">
                                    </TD>


                                </TR>
                                <TR>
                                    <TD>
                                        <input name="btnZero" type="Button" value="  0  " onclick="NumPressed(0)">
                                    </TD>
                                    <TD>
                                        <input name="btnDecimal" type="Button" value="   .  " onclick="Decimal()">
                                    </TD>
                                    <TD>
                                        <input name="btnDecimal" type="Button" value="   OK  " onclick="Valider()">
                                    </TD>

                                </TR>
                            </TABLE>

                    </B>
                </FORM>

                <input type="button" value="Total" class="bigbutton" onclick="javascript:location.href='<?php echo createUrl("newcommand","false")?>';" />
            </td>

        </tr>


    </table>

<!-- This Script is from www.htmlfreecodes.com, Coded by: Krishna Eydat-->




<SCRIPT LANGUAGE="JavaScript">


    $(document).ready(function(){
        $("#barCode").autocomplete("/portlet.php?app=shop_ajax&operation=autocomplete&language=<?php echo $LANG; ?>", {selectFirst: true});
    });
    //

    var FKeyPad = $("#barCode");
    var Accumulate = 0;

    var FlagNewNum = true;
    var PendingOp = "";
    function NumPressed (Num) {

     if (FlagNewNum) {
            FKeyPad.val(Num);
            FlagNewNum = false;
        }
        else {

         FKeyPad.val(FKeyPad.val()+Num) ;
        }
    }


    function Decimal () {
        var curReadOut = FKeyPad.ReadOut.value;
        if (FlagNewNum) {
            curReadOut = "0.";
            FlagNewNum = false;
        }
        else
        {
            if (curReadOut.indexOf(".") == -1)
                curReadOut += ".";
        }
        FKeyPad.ReadOut.value = curReadOut;
    }
    function ClearEntry () {
        FKeyPad.ReadOut.value = "0";
        FlagNewNum = true;
    }
    function Clear () {
        Accumulate = 0;
        PendingOp = "";
        ClearEntry();
    }

    function Valider()
    {


    }

    function deleteproduct(id) {
        $.get('/portlet.php?app=shop_ajax&operation=delete&language=<?php echo $LANG; ?>&articleId='+id, function(data) {
            var res=data.substring(2,5);

            if (res!="div"){


                doPlay('caisseok.wav');
                $("#caisse").html(data);

                //fix for the blank br added
                $.each($('#caisse').textNodes(),function()
                {
                    if ($.trim($(this).text())=="") $(this).remove();
                });

            }
            else{
                doPlay('caisseerror.wav');
                $("#msg").html(data);
            }
    });
    }


$("#barCode").keypress(function (event) {
	if ( event.which == 13 ) {
	    
			  if ($("#barCode").val()!=""){
			  $.get('/portlet.php?app=shop_ajax&operation=add&language=<?php echo $LANG; ?>&barCode='+convertobarcode($("#barCode").val()), function(data) {
				 // $('#result').html(data);
					$("#barCode").val("");
					//alert("/"+data.substring(0,5)+"/");
					var res=data.substring(2,5);
					if (res!="div"){


						doPlay('caisseok.wav');
						$("#caisse").html(data);

                        //fix for the blank br added
                        $.each($('#caisse').textNodes(),function()
                        {
                            if ($.trim($(this).text())=="") $(this).remove();
                        });

                    }
					else{
						doPlay('caisseerror.wav');
						$("#msg").html(data);
					}
				  //alert('Load was performed.');
				});
			  }
	}		 }
			);

$(document).ready(function() {
	$('#barCode').focus();
	});



$('#barCode').focusout(function() {
	$(this).focus();
	  
	});

$(document).focus(function() {
    $('#barCode').focus();
});

function convertobarcode(code)
{
	if (IsNumeric(code)) return code;
var codes=new Array("Ã ","&","é","\"","'","(","-","è","_","ç");
tmp="";
for ( var i = 0; i < code.length; i++) {
	//alert(code+" "+code.substring(i,i+1));
	tmp+=codes.indexOf(code.substring(i,i+1));
}
//alert(tmp);
return tmp;

	}
function getPlayer(pid) {
    var obj = document.getElementById(pid);
    if (obj.doPlay) return obj;
    for(i=0; i<obj.childNodes.length; i++) {
        var child = obj.childNodes[i];
        if (child.tagName == "EMBED") return child;
    }
}
function doPlay(fname) {
    var player=getPlayer("audio1");
    player.play(fname);
}
function doStop() {
    var player=getPlayer("audio1");
    player.doStop();
}
</script>

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"

    width="40"

    height="40"

    id="audio1"

    align="middle">

    <embed src="/flash/wavplayer.swf?h=1&w=1"

       wmode="transparent"

        width="40"

        height="40"

        allowScriptAccess="always"

        type="application/x-shockwave-flash"

        pluginspage="http://www.macromedia.com/go/getflashplayer"

    />

</object>



<script>

function getPlayer(pid) {

	var obj = document.getElementById(pid);

	if (obj.doPlay) return obj;

	for(i=0; i<obj.childNodes.length; i++) {

		var child = obj.childNodes[i];

		if (child.tagName == "EMBED") return child;

	}

}

function doPlay(fname) {

	var player=getPlayer("audio1");

	player.play("/audio/"+fname);

}

function doStop() {

	var player=getPlayer("audio1");

	player.doStop();

}


$(function() {
	function log( message ) {
		$( "<div/>" ).text( message ).prependTo( "#log" );
		$( "#log" ).scrollTop( 0 );
	}

	$( "#birds" ).autocomplete({
		source: "/portlet.php?app=shop_ajax&operation=getClients",
		minLength: 2,
		select: function( event, ui ) {
			log( ui.item ?
				"Selected: " + ui.item.value + " aka " + ui.item.id :
				"Nothing selected, input was " + this.value );
		}
	});
});




    $.get('/portlet.php?app=shop_ajax&operation=list&language=<?php echo $LANG; ?>', function(data) {
        var res=data.substring(2,5);




            $("#caisse").html(data);

            //fix for the blank br added
            $.each($('#caisse').textNodes(),function()
            {
                if ($.trim($(this).text())=="") $(this).remove();
            });



    });



</script>







<style>
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
    #result{
        min-height: 150px;

    }
</style>




<?php } ?>
